package bb.lanxing.fragment.base;

import android.content.Context;
import android.content.DialogInterface;

import bb.lanxing.mvp.base.IUIDelegate;

public class BaseViewFragment extends BaseFragment implements IUIDelegate {
    private IUIDelegate mUIDelegate;

    public BaseViewFragment() {
    }

    public BaseViewFragment(int i) {
        super(i);
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof IUIDelegate) {
            this.mUIDelegate = (IUIDelegate) context;
        }
    }

    @Override
    public void showLoadingDialog(CharSequence charSequence, boolean z, DialogInterface.OnCancelListener onCancelListener) {
        IUIDelegate iUIDelegate = this.mUIDelegate;
        if (iUIDelegate != null) {
            iUIDelegate.showLoadingDialog(charSequence, z, onCancelListener);
        }
    }

    @Override
    public void dismissLoadingDialog() {
        IUIDelegate iUIDelegate = this.mUIDelegate;
        if (iUIDelegate != null) {
            iUIDelegate.dismissLoadingDialog();
        }
    }

    @Override
    public void showLoadingDialog(int i, boolean z, DialogInterface.OnCancelListener onCancelListener) {
        IUIDelegate iUIDelegate = this.mUIDelegate;
        if (iUIDelegate != null) {
            iUIDelegate.showLoadingDialog(getString(i), z, onCancelListener);
        }
    }

    public void autoRefresh() {
        IUIDelegate iUIDelegate = this.mUIDelegate;
        if (iUIDelegate != null) {
            iUIDelegate.autoRefresh();
        }
    }

    public void refreshComplete() {
        IUIDelegate iUIDelegate = this.mUIDelegate;
        if (iUIDelegate != null) {
            iUIDelegate.refreshComplete();
        }
    }

    @Override
    public void loadComplete() {
        IUIDelegate iUIDelegate = this.mUIDelegate;
        if (iUIDelegate != null) {
            iUIDelegate.loadComplete();
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        this.mUIDelegate = null;
    }
}
